package br.eti.robsonfranca.clf4j.javase;

import br.eti.robsonfranca.clf4j.enums.ClearOp;
import br.eti.robsonfranca.clf4j.enums.ColorCode;
import br.eti.robsonfranca.clf4j.impl.Color;
import br.eti.robsonfranca.clf4j.interfaces.Console;
import br.eti.robsonfranca.clf4j.interfaces.UITools;

import com.google.inject.Guice;
import com.google.inject.Inject;

public class Main {

	private Console console;
	private UITools ui;
	
	@Inject
	public Main(Console console, UITools ui) {
		this.console = console;
		this.ui = ui;
	}
	
	public void test() {
		final String message = "Hello World!";
		console.hideCursor();
		console.setForeColor(new Color(ColorCode.WHITE, true));
		console.setBackColor(new Color(ColorCode.BLUE, false));
		console.clrscr(ClearOp.CURSOR_WHOLELINE);		
		console.gotoxy((console.getWidth() - message.length()) >> 1, 3);		
		console.printf(message);
		int k = console.getWidth() - 10;
		ui.box(5, 2, k, 3);
		console.setBackColor(new Color(ColorCode.BLACK, false));
		ui.fillBox(5, 5, k, console.getHeight() - 6);
		char c = console.getChar();
		console.gotoxy(30, 10);
		k = (int) c;
		console.printf("%d", k);
		console.showCursor();	
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Guice.createInjector(new ConsoleModule()).getInstance(Main.class).test();
	}

}
